﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Navigation;

namespace Nok_Air
{
    public partial class CheckInPage : PhoneApplicationPage
    {
        public CheckInPage()
        {
            InitializeComponent();
            DataContext = App.ViewModel;
            /*
            this.bookingNumberTextBox.Text = "10689329";
            this.lastNameTextBox.Text = "CHAROENSRI";
			this.agreeCheckB.IsChecked = true;*/
        }

        private void conditionButton_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/CheckIn/TermAndConditionPage.xaml", UriKind.Relative));
        }

        private void continueButton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(bookingNumberTextBox.Text) || String.IsNullOrEmpty(lastNameTextBox.Text))
            {
                MessageBox.Show(App.ViewModel.FillFormErrorMsg);
                return;
            }
            if (!agreeCheckB.IsChecked.Value)
            {
                MessageBox.Show(App.ViewModel.AgreeErrorMsg);
                return;
            }
            NavigationService.Navigate(new Uri("/CheckIn/2SelectFlightPage.xaml?bookingNumber=" + bookingNumberTextBox.Text + "&lastName=" + lastNameTextBox.Text, UriKind.Relative));
        }

        private void lastNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox box = sender as TextBox;
            Validator.validateName(box);
        }

        private void bookingNumberTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox box = sender as TextBox;
            Validator.validateNumber(box);
        }
    }
}